package com.gitee.starblues.grape.core.builder;


import com.gitee.starblues.grape.core.domain.user.RebateAccountLog;
import com.gitee.starblues.grape.repository.databases.entity.RebateAccountLogPo;
import com.gitee.starblues.grape.repository.databases.entity.RebateDrawLogPo;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class RebateAccountLogBuilder {
	public static RebateAccountLog build(RebateAccountLogPo source) {
		RebateAccountLog target = new RebateAccountLog();
		BeanUtils.copyProperties(source, target);
		return target;
	}
	
	public static List<RebateAccountLog> build(List<RebateAccountLogPo> source) {
		List<RebateAccountLog> result = new ArrayList<RebateAccountLog>();
		for (RebateAccountLogPo po : source) {
			result.add(RebateAccountLogBuilder.build(po));
		}
		return result;

	}
	
	public static RebateAccountLogPo buildDraw(RebateDrawLogPo po) {
		RebateAccountLogPo account = new RebateAccountLogPo();
		account.setAmount(po.getAmount());
		// 支出
		account.setType(1);
		account.setRemark("提现");
		account.setUserId(po.getUserId());
		return account;
	}
}
